<template>
    <div class="news">
      <input class="rr" type="text" v-model="message"/>
      <button class="tt" v-on:click="dealMessage">发送</button>
      <router-link to="/chat">Go to Chat</router-link>
      <ul>
        <li v-for="item in message_array" class="gg">
          <span class="cc">{{item}}</span>
        </li>
        <li> </li>
      </ul>
    </div>
</template>
<script>
export default {
  name: 'NewSee',
  data: function () {
    return {
      message_array: [],
      message: ''
    }
  },
  methods: {
    dealMessage: function () {
      this.message_array.push((new Date()).Format('yyyy-M-d h:m:s') + ': ' + this.message)
      this.message = ''
    }
  }
}
Date.prototype.Format = function (fmt) { // author: meizz
  var o = {
    'M+': this.getMonth() + 1, // 月份
    'd+': this.getDate(), // 日
    'h+': this.getHours(), // 小时
    'm+': this.getMinutes(), // 分
    's+': this.getSeconds(), // 秒
    'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
    'S': this.getMilliseconds() // 毫秒
  }
  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
  for (var k in o) { if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) }
  return fmt
}
</script>

<style scoped lang="stylus">
  .news
    margin-top .1rem
    .rr
      position: absolute;
      border: 2px solid #7BA7AB;
      border-radius: 5px;
      background: #F9F0DA;
      color: #9E9C9C;
      margin-top 230px
      width 70%
    .tt
      position: absolute;
      width 20%
      top: 0;
      right: 0;
      background: #2fdaff;
      border-radius: 0 5px 5px 0;
      margin-top 650px
    .cc
      background-color #4dec45
</style>
